#include "stm32f10x.h"                  // Device header
#include "playmusic.H"
#include "stm32f10x.h"           
#include "OLED.h"
#include "systick.h"
int i,time,j,a[]={                                                           //音调
		    1635,1376, 917,1376,2062,1836,1635, 917,1376,1376,1836, 917,1376,1376,
		     917,1456, 917,1635,1376, 917,1376,2062,1836,1635, 917,1376,1376,1836,
	         917,1376,1376, 917,1836,1376, 917,                             //前奏 34
	          30, 917, 917,1376,1376,1226,1092,                              //故事的小黄花 41
	          30, 917, 917,1376,1376,1226,1092,1226,1376,1836,               //从出生那年就飘着 51  
	          30, 917, 917,1376,1376,1226,1092,                              //童年的荡秋千 58 
	          30,1092,1226,1092,1031,1092,1226,1031,1092,1226,1376,          //随记忆一直晃到现在 69
	        1836,1376,1376,1092,1031,1092,1226,                              //Re So So Si Do Si La 76
	        1376,1226,1092,1092,1092,1092,1226,1092,1226,1376,               //So La Si Si Si Si La Si La So 86 
	        1836,1376,1226,1092,1031,1092,1226,1376,                         //吹着前奏 望着天空 94
	        1226,1092,1092,1092,1092,1226,1092,1226,1376,                    //我想起花瓣试着掉落 103 
	          30,1376,1376,1376,1376,1635,1456,1376, 917,1031,1092,1376,1367,//没想到 失去的勇气我还留着 116
	          30,1376,1376,1376,1376,1092,1376,                               //好想再问一遍 123
	        1635,1456,1376, 917,1031,1092,1376,1226,                          //你会等待还是离开 131
	        1092,1226,1031,1092,1376, 917, 728, 687, 728, 917,1376,           //刮风这天 我试过握着你手 142
        	  30,1376, 817, 817,  30, 817, 917, 917,                          //但偏偏 雨渐渐 150
	          30, 917,1031,1092,1226,1092,1031,1092,                          //大到我看你不见 158
	          30,1092,1031, 917,1092,  30,1031, 917, 728, 612, 728, 687, 687, //还要多久 我才能在你身边 171 
	          30, 687, 687, 917, 917, 817, 917,1031,                          //等到放晴的那天 179
	        1226,1092, 1031, 917, 817,1376,817, 728, 728,                     //也许我会比较好一点 188
	        1092,1226,1031,1092,  30,1376, 917, 728, 687, 728, 917,1376,      //从前从前 有个人爱你很久 200
     		  30,1376, 817, 817,  30, 817, 917, 917,                          //但偏偏 风渐渐 208
			  30, 917,1031,1092,1226,1092,1031,1092,                          //大到我看你不见 216
			  30,1092,1031, 917,1092,  30,1031, 917, 728, 612, 728, 687, 687, //好不容易 又能再多爱一天 229
			  30,1376, 687, 917, 917, 817, 917,                               //但故事的最后 236
			1031,1635,1456,1376,1226,1092,1226,30,1092,1376                   //你好像还是说了 拜拜 246
		  };

int tm[]={                                                  //音调时长
		  50, 50, 50, 50, 50, 25, 25, 50, 50, 50, 50, 50, 50, 50,
	      50, 50, 50, 50, 50, 50, 50, 50, 25, 25, 50, 50, 50, 50,
	      50, 50, 50, 50, 25, 25, 50,                       //前奏  
	      50, 50, 50, 50,100, 50, 50,                       //故事的小黄花
          50, 50, 50, 50, 50, 25, 25, 25, 25, 50,           //从出生那年就飘着
       	  50, 50, 50, 50,100, 50, 50,                       //童年的荡秋千  
	      50,100, 25, 25, 25, 25, 25, 25, 25, 25, 50,       //随记忆一直晃到现在
     	  50, 50, 50, 50, 50, 50, 50,                        //Re So So Si Do Si La
      	  25, 25, 50, 50, 50, 50, 25, 25, 50,100,            //So La Si Si Si Si La Si La So 
	      50, 50, 50, 50, 50, 50, 50, 25,                    //吹着前奏 望着天空
     	  25, 50, 50, 50, 50, 25, 25, 50, 75,                //我想起花瓣试着掉落 
	     400, 25, 25, 25, 25, 50, 50, 50, 50, 50, 50, 50,125,//没想到 失去的勇气我还留着 
	      50, 25, 25, 25, 25, 50, 50,                        //好想再问一遍
	      50, 50, 50, 50, 50, 50, 50,130,                    //你会等待还是离开
	      50, 50, 50,100, 50, 50, 50, 50, 50, 50, 50,        //刮风这天 我试过握着你手
	      50, 50, 50, 50, 50, 50, 50, 50,                    //但偏偏 雨渐渐 
	      50, 50, 50, 50, 50, 50, 50,125,                    //大到我看你不见
	      75, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,125,//还要多久 我才能在你身边  
	      50, 50, 50, 50, 50, 50, 50, 50,                    //等到放晴的那天
	      50, 50, 50, 50, 50, 50, 75, 25,100,                //也许我会比较好一点
	      50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,    //从前从前 有个人爱你很久
		  50, 50, 50, 50, 50, 50, 50, 50,                    //但偏偏 风渐渐 
		  50, 50, 50, 50, 50, 50, 50,150,                    //大到我看你不见
		  50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,125,//好不容易 又能再多爱一天 
		  50, 50, 50, 50, 50, 50, 50,                        //但故事的最后
		  50, 50, 50, 50, 50, 50,100, 20, 50,200,            //你好像还是说了 拜拜
		};
//void show_tone(void)
//{
//	switch (a[i])
//    {
//    	case 2747:OLED_ShowString(2,6,"-C");
//    		break;
//    	case 2448:OLED_ShowString(2,6,"-D");
//    		break;
//     	case 2181:OLED_ShowString(2,6,"-E");
//    		break;
//    	case 2062:OLED_ShowString(2,6,"-F");
//    		break;
//    	case 1836:OLED_ShowString(2,6,"-G");
//    		break;
//    	case 1635:OLED_ShowString(2,6,"-A");
//    		break;
//    	case 1456:OLED_ShowString(2,6,"-B");
//    		break;
//		case 1376:OLED_ShowString(2,6," C");
//    		break;
//    	case 1226:OLED_ShowString(2,6," D");
//    		break;
//     	case 1092:OLED_ShowString(2,6," E");
//    		break;
//    	case 1031:OLED_ShowString(2,6," F");
//    		break;
//    	case 917:OLED_ShowString(2,6," G");
//    		break;
//    	case 817:OLED_ShowString(2,6," A");
//    		break;
//    	case 728:OLED_ShowString(2,6," B");
//    		break;
//		case 687:OLED_ShowString(2,6,"+C ");
//    		break;
//    	case 612:OLED_ShowString(2,6,"+D ");
//    		break;
//     	case 545:OLED_ShowString(2,6,"+E ");
//    		break;
//    	case 514:OLED_ShowString(2,6,"+F ");
//    		break;
//    	case 458:OLED_ShowString(2,6,"+G ");
//    		break;
//    	case 408:OLED_ShowString(2,6,"+A ");
//    		break;
//    	case 363:OLED_ShowString(2,6,"+B ");
//    		break;
//		default:
//    		break;
//    }
//}	
void B_Music(void)
{
	
//	OLED_Init();

//	OLED_ShowString(2,1,"tone:");
//	OLED_ShowString(1,1,"JAY-CHOU YYDS");
	int c;
	for(i=0;i<=246;i++)
	{
        
	
//		show_tone();
		c=5;j=tm[i]/25;
		time=j*180;
		if(i==49||i==67||i==178)
		{
			c=0;
		}
	
		Play_Music(a[i],time,c);
	}
}
